package com.ccbft.msgcenter.producer.contoller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ccbft.msgcenter.producer.service.ProducerSendService;

@RestController
@RequestMapping(value="send")
public class MessageProductContoller {

	@Autowired
	private ProducerSendService kafkaMessageSendService;

	@RequestMapping(value = "/sendMessage/{topic}", method = RequestMethod.POST)
	public String urlProducer(@PathVariable(value="topic",required=true) String topic,@RequestBody String message) {
		try {
			kafkaMessageSendService.send(topic,message);
		} catch (Exception e) {
			return e.getMessage();
		}
		return message;
	}
}
